<include file='Public/header'/>
<style>
.more1{
text-align:center;
width:100%;
height:2.5rem;
line-height:2.5rem;
}

</style>
	<body>
		<div class="mui-content">
		    <header class="mui-bar mui-bar-nav pub_head">
		        <a class="mui-action-back mui-icon mui-pull-left iconfont icon-left" href="javascript:history.go(-1)"></a>
		        <h1 class="mui-title">通知公告</h1>
		        <a class="mui-icon mui-pull-right iconfont icon-house1" style="font-size:26px;padding-top:0.5rem;" href='/'></a>
		    </header>
		    <ul class="mui-table-view noti-cont mTop" id='list'>

				<?php if($data){
                               foreach($data as $key=>$val){ ?>

		        <li class="mui-table-view-cell mui-media">
		            <a href="{:U('Notice/detail',array('id'=>$val['id']))}" style="display: flex;">
		                <img class="mui-media-object mui-pull-left" src="{$val['picture']}">
		                <div class="mui-media-body noti-title">
		                    {$val['title']}
							<p class="mui-ellipsis"><?php echo mb_substr($val[ 'intro'],0,80, 'utf-8'). '......'; ?></p>
		                </div>
                                <span class="noti_time">{$val['add_time']|date="Y-m-d ",###}</span>
		            </a>
		        </li>     
				<?php } } ?>
					
				<if condition="empty($data)">
					<div class="mui-content">
						<div class="no-message">
							<i class="iconfont icon-zanwuxiaoxitixing"></i>
							<p>暂无消息</p>
						</div>
					</div>
				</if>
			</ul>
			<input type='hidden' name='uid' class='uid' value="{:I('uid')}" />
			<p class='more1' style='display:none;'>已经到底了！</p>
		</div>
	</body>
</html>
<script>
        var p=2;
        var uid =$('.uid').val();
        var d = document.getElementById("list").offsetHeight;
        window.addEventListener("scroll", function(event) {
            var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;  
            if(document.documentElement.scrollHeight == document.documentElement.clientHeight + scrollTop ) {
              getData();
            }        
        });
        function getData(){
            $('#jiazai').show();
            $.ajax({
                url:"{:U('getData')}",
                type:"get",
                data:{p:p,uid:uid},
                success:function(e){
                	console.log(e);
                    if(e==1){
                            $('.more1').css('display','block');
                    }else{
                         p++;
                         setTimeout(function(){
                            $('#list').append(e);
                            $('#jiazai').hide();
                         },2000);
                        
                    }
                   
                }
            })
        }
    </script>
